package com.qin.springcloud.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.qin.springcloud.bean.Users;

@RestController
public class UsersConsumerLbController {

	@Autowired
	private RestTemplate restTemplate;
											   
	private final static String REST_PREFIX = "http://springcloud-provider-users"; 

	@GetMapping("/consumerlb/get/{id}")
	public Users getById(@PathVariable int id){
		return restTemplate.getForObject(REST_PREFIX+"/users/get/"+id, Users.class);
		
	}
	
	@SuppressWarnings("unchecked")
	@GetMapping("/consumerlb/getAll")
	public List<Users> getById(){
		return restTemplate.getForObject(REST_PREFIX+"/users/getAll", List.class);
		
	}
}

